#include <iostream>
#include <functional>
#include <string>

using std::cout;
using std::endl;
using std::function;
using std::string;

void print()
{
    cout << "hello" << endl;
}
void test()
{
    int a = 10;
    //只是相当于定义了一个函数，但是并没有调用它
    function<void(int)> f = [&a](int value){
        cout << "value = " << value << endl;
        ++a;
        cout << "a = " << a << endl;
    };

    cout << "-----------" << endl;
    f(100);

    cout << endl << endl;
    function<void(const string &,int)> f2 = 
        [](const string &name, int value) {
        cout << "name = " << name << endl;
        cout << "vaule = " << value << endl;
    };
    f2("hello", 100);

}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

